package home.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.layout.SingleLayoutHelper;

import net.ck.hzq.R;

import ui.activity.home.EnterPriseAct;

public class NewsTitleAdapter extends DelegateAdapter.Adapter<NewsTitleAdapter.NewsTitleVH> {

    private final Context mContext;

    public NewsTitleAdapter(Context context) {
        mContext = context;
    }

    public void setupData() {

    }

    @Override
    public LayoutHelper onCreateLayoutHelper() {
        return new SingleLayoutHelper();
    }

    @NonNull
    @Override
    public NewsTitleVH onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new NewsTitleVH(LayoutInflater.from(mContext).inflate(R.layout.item_home_news_title, viewGroup,
                false));
    }

    @Override
    public void onBindViewHolder(@NonNull NewsTitleVH holder, int i) {
        holder.more.setOnClickListener(v -> {
            Intent intent = new Intent(mContext, EnterPriseAct.class);
            mContext.startActivity(intent);
        });
    }

    @Override
    public int getItemCount() {
        return 1;
    }

    class NewsTitleVH extends RecyclerView.ViewHolder {
        private TextView more;

        NewsTitleVH(@NonNull View itemView) {
            super(itemView);
            more = itemView.findViewById(R.id.more);
        }
    }

}
